package com.dao;

import java.util.Collection;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import com.bean.Admin;

@Repository("adminDao")
public class AdminDao extends HibernateDaoSupport
{
	public boolean login(Admin admin) throws Exception
	{

	  return this.getHibernateTemplate().contains(admin);
//		Session session = sessionFactoryUtil.opensession();
//		Transaction tx = null;
//		try{
//			tx = session.beginTransaction();
//			Query query = session.createQuery("from Admin as u where u.name='"+admin.getName()+"' and u.password='"+admin.getPassword()+"'");
//			@SuppressWarnings("rawtypes")
//			Collection list = query.list();
//			tx.commit();
//			if(list.isEmpty() == false){
//				return true;
//			}
//			else {
//				return false;
//			}
//			}
//		catch(Exception e){
//			tx.rollback();
//			throw e;	
//			}
//		finally{
//			session.close();
//			}			
//		
		
	}

}
